<!DOCTYPE html>
<html lang="en">
<head>
    <meta http-equiv="Content-Type" content="multipart/form-data; charset=utf-8"/>
    <title>驾校报名</title>
    <link rel="stylesheet" href="css/fore/order.css">
    <link rel="stylesheet" href="css/fore/index.css">
    <script src="js/jquery/2.0.0/jquery.min.js"></script>
    <link href="css/bootstrap/3.3.6/bootstrap.min.css" rel="stylesheet">
    <script src="js/bootstrap/3.3.6/bootstrap.min.js"></script>
    <script src="js/vue.min.js"></script>
    <script src="js/fetch.min.js"></script>
    <script src="js/axios.min.js"></script>
    <script>
        $(function () {
            $("#register").click(function () {
                if (0 === $("#username").val().length) {
                    alert("请输入用户名");
                    return false;
                }
                if (0 === $("#password").val().length) {
                    alert("请输入密码");
                    return false;
                }
                if (0 === $("#password_confirm").val().length) {
                    alert("请输入重复密码");
                    return false;
                }
                if ($("#password").val() !== $("#password_confirm").val()){
                    alert("两次输入密码不同")
                    return false;
                }
                if (0 === $("#pic").val().length) {
                    alert("请选择要上传的头像");
                    return false;
                }
                let formData = new FormData(document.getElementById("register_form"));
                console.log(formData.toString());
                $.ajax({
                    type: "POST",
                    url: "fore_student_register",
                    dataType: 'json',
                    data: formData,
                    contentType: false,
                    processData: false,
                    success: function (msg) {
                        let flag = msg.flag;
                        switch (flag) {
                            case 0: alert("头像文件类型出错"); break;
                            case 1: let answer = confirm("注册成功 是否进入登陆页面");
                                    if(answer)
                                        window.location ="login.html"; break;
                            case -1: alert("用户名已存在"); break;
                            case 2: alert("头像上传失败");
                            case 20: alert("用户名太长");

                        }
                    }
                });
                return false;
            });

        });

    </script>
</head>
<body style="min-height: 800px;">
<div class="header">
    <div class="top">
        <div class="top-logo fl">
            <a id="logo" href="index.html"><img src="img/car-logo.png" alt="" class="fl"
                                                                style="margin-top: 20px;width: 45px"><span
                    class="top-logo-text">练车预约系统</span></a>
        </div>
    </div>
    <div class="header-nav">
        <ul id="nav-list">
            <li class="nav-list-li"><a href="index.html">首页</a></li>
            <li class="nav-list-li"><a href="selectcoach.html">明星教练</a></li>
            <li class="nav-list-li"><a href="testorder.html">考试报名</a></li>
            <li class="nav-list-li"><a href="order.html">练车预约</a></li>
            <li class="nav-list-li"><a href="teachingvideo.html">驾考视频</a></li>
            <li class="nav-list-li"><a href="register.html">驾校报名</a></li>
        </ul>
    </div>
</div>
<link href="css/fore/text.css" rel="stylesheet" type="text/css">
<div class="sign-rules">
    <div class="sign-rules-title">报名须知</div>
    <div class="sign-rules-each">1.申请小型汽车、小型自动挡汽车、轻便摩托车准驾车型的，在18周岁以上，70周岁以下。
    </div>
    <div class="sign-rules-each">2.申请低速载货汽车、三轮汽车、普通三轮摩托车、普通二轮摩托车或者轮式自行机械车准驾车型的，在18周岁以上，60周岁以下。
    </div>
    <div class="sign-rules-each">3.申请城市公交车、中型客车、大型货车、无轨电车或者有轨电车准驾车型的，在21周岁以上，50周岁以下。
    </div>
    <div class="sign-rules-each">4.申请牵引车准驾车型的，在24周岁以上，50周岁以下。
    </div>
    <div class="sign-rules-each">5.申请大型客车准驾车型的，在26周岁以上，50周岁以下。</div>
</div>
<br>
<br>
<br>
<link href="css/fore/home_login.css" rel="stylesheet" type="text/css">
<div class="nc-login-layout">
    <div class="nc-login">
        <div class="nc-login-title">
            <h3>驾校报名</h3>
        </div>
        <div class="nc-login-content">
            <form id="register_form" method="post"  onsubmit="return false" enctype="multipart/form-data">
                <dl>
                    <dt>账户名</dt>
                    <dd style="min-height:30px;">
                        <input type="text" id="username" name="username" class="text tip"
                               title="3-20位字符，可由中文、英文、数字及“_”、“-”组成" required/>
                        <label></label></dd>
                </dl>
                <dl>
                    <dt>设置密码</dt>
                    <dd style="min-height:30px;">
                        <input type="password" id="password" name="password" class="text tip"
                               title="6-16位字符，可由英文、数字及标点符号组成" required/>
                        <label></label></dd>
                </dl>
                <dl>
                    <dt>确认密码</dt>
                    <dd style="min-height:30px;">
                        <input type="password" id="password_confirm" name="password_confirm" class="text tip"
                               title="请再次输入您的密码" required/>
                        <label></label></dd>
                </dl>
                <dl>
                    <dt>真实姓名</dt>
                    <dd style="min-height:30px;">
                        <input type="text" id="name" name="name" class="text tip"
                               title="3-20位字符，可由中文、英文、数字及“_”、“-”组成" required/>
                        <label></label></dd>
                </dl>
                <dl>
                    <dt>手机</dt>
                    <dd style="min-height:30px;">
                        <input type="number" id="phone" name="phone" class="text tip" title="请输入手机号码，便于我们联系您" required/>
                        <label></label></dd>
                </dl>
                <dl>
                    <dt>头像</dt>
                    <dd style="min-height:30px;">
                        <input id="pic" name="pic" accept="image/jpg, image/jpeg, image/png" type="file" title="头像" required/>
                        <label></label></dd>
                </dl>
                <dl>
                    <dt>性别</dt>
                    <dd style="min-height:40px;">
                        <select name="sex" style="width: 100px; height: 30px">
                            <option value="男">男</option>
                            <option value="女">女</option>
                        </select>
                    </dd>
                </dl>
                <dl>
                    <dt>位置</dt>
                    <dd style="min-height:30px;">
                        <input type="text" id="locate" name="locate" class="text tip" title="请输入位置，便于本驾校教车接送" required/>
                        <label></label></dd>
                </dl>
                <dl>
                    <dt>驾驶证种类</dt>
                    <dd style="min-height:54px;">
                        <select name="carModel" STYLE="width: 100px;">
                            <option value="A1">A1</option>
                            <option value="A2">A2</option>
                            <option value="A3">A3</option>
                            <option value="B1">B1</option>
                            <option value="B2">B2</option>
                            <option value="C1" selected>C1</option>
                            <option value="C2">C2</option>
                            <option value="C3">C3</option>
                            <option value="C4">C4</option>
                        </select>
                        <label></label>
                    </dd>
                </dl>

                <dl>
                    <dt>&nbsp;</dt>
                    <dd>
                        <button id="register" style="float: left">立即注册</button>
                        <input name="agree" type="checkbox" class="fl mt10 ml10" id="clause" value="1" checked="checked" style="margin-left: 10px"/>
                        <span for="clause" class="fl ml5">阅读并同意<a href="#nowhere" class="agreement"
                                                                  title="阅读并同意">服务协议</a></span>
                        <label></label></dd>
                </dl>
            </form>
            <div class="clear">
            </div>
        </div>
        <div class="nc-login-bottom">
        </div>
    </div>
</div>

<div class="footer">
    <p>
        Good CarTeacher©2018 | QQ:123456789
        <a href="#">|关于我们</a>
        <a href="login.html">|驾校登录</a>
    </p>
</div>


</body>
</html>
